package com.chisheng.caa.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.chisheng.caa.mapper.CourseAffiliationMapper;
import com.chisheng.caa.pojo.dto.CourseAffiliationDTO;
import com.chisheng.caa.pojo.entity.CourseAffiliation;
import com.chisheng.caa.service.CourseAffiliationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class CourseAffiliationServiceImpl implements CourseAffiliationService {

    @Resource
    private CourseAffiliationMapper courseAffiliationMapper;

    @Override
    public List<CourseAffiliationDTO> getCourseAffiliationList() {
        return courseAffiliationMapper.selectList(null).stream().map(courseAffiliation -> {
            CourseAffiliationDTO dest = new CourseAffiliationDTO();
            BeanUtil.copyProperties(courseAffiliation, dest);
            return dest;
        }).collect(Collectors.toList());
    }

    @Override
    public List<String> getCourseAffiliationNameList() {
        return courseAffiliationMapper.selectList(null).stream().map(CourseAffiliation::getAffiliationName)
                .collect(Collectors.toList());
    }

}
